package service;

import dao.RoleDao;
import domin.Role;
import exception.tsglException;
import util.Condition;
import util.JdbcHelper;
import util.Pagination;

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.SQLIntegrityConstraintViolationException;
import java.util.Collection;
import java.util.List;

public final class RoleService {
    private static final RoleDao roleDao = RoleDao.getInstance();
    private static final RoleService roleService = new RoleService();


    public static RoleService getInstance() {
        return roleService;
    }

	public Collection<Role> findAll(Pagination pagination, List<Condition> conditionList) throws SQLException {
		Connection connection = JdbcHelper.getConn();
		Collection<Role> roles = roleDao.findAll(connection, pagination, conditionList);
		JdbcHelper.close(connection);
		return roles;
	}
	public Role find(Integer id) throws SQLException {
		Connection connection = JdbcHelper.getConn();
		Role role = roleDao.find(connection, id);
		JdbcHelper.close(connection);
		return role;
	}

}
